{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">水票购买 / 核销记录</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('tickets.history/add')}"
                   data-auth-edit="{:$auth->check('tickets.history/edit')}"
                   data-auth-delete="{:$auth->check('tickets.history/del')}"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/html" id="picTpl">

    <img style="max-width:80px; max-height:30px;" src="{{d.img}}" data-image="{{d.name}}">

</script>
<script type="text/html" id="imgTpl">
    <img src="{{ d.img }}">
</script>

<script type="text/html" id="barTool">
    {if $userInfo['roleid']==1}
    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="编辑内容"
       data-full="true">编辑</a>
    <a href='{:url("del",["catid"=>$catid])}?ids={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
    {/if}
</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="上架|下架" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
        };

        table.render({
            init: init,
            toolbar: ['refresh'],
            url: '{:url("index")}',
            search: true,
            cols: [
                [
                    {field: 'id', width: '10%', title: 'ID',search: false},
                    {field: 'tcname', width: '20%', title: '水票名称', search: false},
                    {field: 'username',width: '20%', title: '用户', search: false},
                    {field: 'member_id',width: '10%', title: '用户id',hide: true },
                    {field: 'num', width: '20%', title: '水票数量',search: false},
                    {field: 'type', width: '10%', title: '类型',templet: function (d) {
                            if (d.type == 1) {
                                return '<span style="color: orange">购买</span>';
                            }else if(d.type == 2){
                                return '<span style="color: green">核销</span>';
                            }else {
                                return '<span style="color: #0000FF">其他</span>';
                            }
                        },  selectList: {1: '购买', 2: '核销'}},
                    {field: 'create_time', width: '22%', title: '创建时间',search: false},
                ]
            ],
            page: {}
        });

        yznTable.bindevent();
    });
</script>
{/block}